#{extends 'main.html' /}

#{navigation /}

<div class="content">
		<div id="breadcrumb">
		<a href="@{Courses.index}">Courses</a> → <a href="@{Courses.show(lecture.course.id)}">${lecture.course.name}</a> → <a href="@{Lectures.show(lecture.id)}">${lecture.name}</a> → ${question.title}
	</div>
	
	<h1>${question.title}</h1>
	<span>
	${question.content}<br>
	</span>
	-- ${question.postedBy.name}<br><br>
	
	Votes: ${question.voters.size()}<br>
	#{if user.isPremium}
		#{if user.hasVotedFor(question)}
		<a href="@{Questions.unvoteQuestion(question.id)}">unvote</a>
		#{/if}
		#{else}
		<a href="@{Questions.voteOnQuestion(question.id)}">vote</a>
		#{/else}
	#{/if}
	
	<h2>Comments</h2>
	#{list items:comments, as:'comment'}
		<span>
			${comment.postedAt.format('dd-mm-yyyy, hh:ss')}<br>
			${comment.content} <br>
			--- ${comment.postedBy.name}
			#{if comment.postedBy.name == user.name}<a href="@{Questions.deleteComment(question.id, comment.id)}">Delete</a>#{/if}<br><br>
		</span>
	#{/list}
	
	#{form @Questions.addComment(question.id)}
	<span id="comment-field">
			<label for="content">Posting as ${user.name}</label><br>
			<textarea type="text" name="content" id="content"></textarea><br>
			<input type="submit" id="submit" value="comment" />
			<br>
	</span>
	#{/form}
	
	#{if user.isExpert}
	#{form @Answers.addAnswer(question.id)}
	<span id="comment-field">
			<label>Answering as ${user.name}</label><br>
			<input type="text" name="title" id="title" value="title.."/><br>
			<textarea type="text" name="content" id="content"></textarea><br>
			<input type="submit" id="submit" value="answer" />
	</span>
	#{/form}
	#{/if}
</div>